<?php 
namespace Emos\Field;

use Emos\Common;

class Textarea extends Text {
    protected $height = null;
    
    public function setHeight($height) {
        $this->height = $height;
        return $this;
    }

    public function html() {
        $s = $this->height ? "height:{$this->height}px" : '';
        return "<textarea name='{$this->htmlName}' style='{$s}'>".Common::plain($this->value)."</textarea>";
    }
   
    public function getDdlFields() {
        return array(
            $this->dbName => "MEDIUMTEXT"
        );
    }     
    
    public function getFake() {        
        $fake = new \Emos\Fake();
        
        $text = '';
        $sentNum = rand(1,5);        
        for($s=0; $s<$sentNum; $s++) {
            $text .= $fake->getSentence() . '. ';
        }
        
        return array(
            $this->dbName => "'".$this->escapeSqlStr($text)."'"
        );
    }    
}